package 增减字符串匹配;

class Solution {
    public int[] diStringMatch(String s) {
        int n = s.length(), l = 0, r = n;
        int[] ret = new int[n + 1];
        for (int i = 0; i < n; i++) {
            if (s.charAt(i) == 'I') {
                ret[i] = l;
                l++;
            } else {
                ret[i] = r;
                r--;
            }
        }
        ret[n] = l;
        return ret;
    }
}
